import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.*;
import java.util.Properties;

public class DruidTest2 {
    public static void main(String[] args) {
        ResultSet resultSet = null;
        PreparedStatement statement = null;
        Connection connection = null;
        InputStream fis = null;

        try {
            Properties p = new Properties();
            fis = (DruidTest2.class.getClassLoader().getResourceAsStream("util.properties"));
            p.load(fis);

            DataSource createDataSource = DruidDataSourceFactory.createDataSource(p);
            connection = createDataSource.getConnection();

            statement = connection.prepareStatement("select *from `account`");
            resultSet = statement.executeQuery();

            while (resultSet.next()) {
                System.out.println("id:" + resultSet.getInt("id"));
                System.out.println("name:" + resultSet.getString("name"));
                System.out.println("money:" + resultSet.getObject("money"));
            }


        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                resultSet.close();
                statement.close();
                connection.close();
                fis.close();
            } catch (Exception throwables) {
                throwables.printStackTrace();
            }
        }


    }

}


/*五月 20, 2021 8:19:37 下午 com.alibaba.druid.pool.DruidDataSource info
        信息: {dataSource-1} inited
        id:1
        name:A
        money:2000.00
        id:2
        name:B
        money:1000.00
        id:3
        name:王五
        money:3000.00
        id:4
        name:赵六
        money:4000.00*/





















